package my.li.zhcsmanagerfront.controller;

import Vo.Manger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/main")
public class MainController {



    @RequestMapping("/toRent")
    public String do1(HttpServletRequest request) {
        if(isOk(request) ){
            return "redirect:http://localhost:8000/house/";
        }else {
            return "redirect:http://localhost:8080/";
        }

    }

    @RequestMapping("/toPropertyfee")
    public String do2(HttpServletRequest request) {
        if(isOk(request)){
            return "redirect:http://localhost:8000/fee/";
        }else {
            return "redirect:http://localhost:8080/";
        }

    }

    @RequestMapping("/toMedicalPay")
    public String do3(HttpServletRequest request){
        if(isOk(request)){
            return "redirect:http://localhost:9000/medical/";
        }else {
            return "redirect:http://localhost:8080/";
        }
    }

    @RequestMapping("/toWuliu")
    public String d4(HttpServletRequest request){
        if(isOk(request)){
            return "redirect:http://localhost:5000/wuliu/";
        }else {
            return "redirect:http://localhost:8080/";
        }
    }
    @RequestMapping("/toLand")
    public String do5(HttpServletRequest request) {
        if(isOk(request)){
            return "redirect:http://localhost:7000/land/";
        }else {
            return "redirect:http://localhost:8080/";
        }
    }

    @RequestMapping("/toStore")
    public String do6(HttpServletRequest request) {
        if(isOk(request)){
            return "redirect:http://localhost:7000/store/";
        }else {
            return "redirect:http://localhost:8080/";
        }
    }

    public boolean isOk(HttpServletRequest request){
//        HttpSession session = request.getSession(false);
//        if(session == null){
//            return false;
//        }
//        System.out.println(session);
//        Object user = session.getAttribute("user");
//        System.out.println(user);
//        if(user instanceof Manger){
//            return true;
//        }else {
//            return false;
//        }
        return true;
    }
}
